package com.ticket.sass.admin.controller;

import com.ticket.sass.admin.annotation.Loggable;
import com.ticket.sass.admin.annotation.Module;
import com.ticket.sass.admin.business.TicketOrderBusiness;
import com.ticket.sass.admin.dto.input.LaterPayRefundStatusInput;
import com.ticket.sass.admin.dto.input.order.RefundRecordInput;
import com.ticket.sass.admin.dto.output.order.RefundApplyRecordListOutput;
import com.ticket.sass.admin.model.PageModel;
import com.ticket.sass.admin.model.ResultModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author ywb
 * @date 2024-05-07 18:49
 */
@RestController
@Api(tags = {"先看后付接口"})
@RequestMapping("/later-pay-refund-records")
public class RefundApplyRecordController {
    final TicketOrderBusiness business;
    
    public RefundApplyRecordController(TicketOrderBusiness business) {
        this.business = business;
    }
    
    @GetMapping
    @ApiOperation("列表")
    public ResultModel<PageModel<RefundApplyRecordListOutput>> list1(
        @Valid RefundRecordInput input
    ) {
        return ResultModel.success(
            business.refundRecord(input)
        );
    }
    
    @PutMapping("/status")
    @ApiOperation("状态审核")
    @Loggable(module = Module.PAY_AFTER_WATCH, desc = "状态修改")
    public ResultModel<String> status(
        @RequestBody @Valid LaterPayRefundStatusInput input
    ) {
        business.updateStatus(input);
        return ResultModel.success();
    }
}
